package com.bwie.system.controller;

import com.bwie.common.domain.RedPacket;
import com.bwie.common.domain.RedPacketReceived;
import com.bwie.common.domain.request.RedPacketAdd;
import com.bwie.common.domain.request.RedPacketReqList;
import com.bwie.common.domain.response.RedPacketVo;
import com.bwie.common.result.Result;
import com.bwie.system.mq.domain.EsRedPacketReceived;
import com.bwie.system.service.EsRedPacketReceivedService;
import com.bwie.system.service.RedPacketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author Junchen_N1
 * @Date 2025/6/17 13:33
 * @ClassName RedPacketController
 * @Description TODO
 */
@RestController
@RequestMapping("/packet")
public class RedPacketController {

    @Autowired
    private RedPacketService redPacketService;

    @Autowired
    private EsRedPacketReceivedService esRedPacketReceivedService;

    @PostMapping("/selectRedPacketList")
    public Result<List<RedPacketVo>> selectRedPacketList(@RequestBody RedPacketReqList redPacketReqList){
        return redPacketService.selectRedPacketList(redPacketReqList);
    }

    @PostMapping("/addRedPacket")
    public Result addRedPacket(@RequestBody @Valid RedPacketAdd redPacketAdd){
        redPacketService.addRedPacket(redPacketAdd);
        return Result.success();
    }

    @GetMapping("/snatchRedPacket/{redPacketId}")
    public Result snatchRedPacket(@PathVariable("redPacketId") Integer redPacketId){
        redPacketService.snatchRedPacket(redPacketId);
        return Result.success();
    }

    @GetMapping("/selectSnatchMsg/{redPacketName}")
    public Result<List<EsRedPacketReceived>> selectSnatchMsg(@PathVariable("redPacketName") String redPacketName){
        return esRedPacketReceivedService.selectSnatchMsg(redPacketName);
    }

    @GetMapping("/selectMsgOfRedPacket/{redPacketId}")
    public Result<List<EsRedPacketReceived>> selectMsgOfRedPacket(@PathVariable("redPacketId") Integer redPacketId){
        return esRedPacketReceivedService.selectMsgOfRedPacket(redPacketId);
    }

}
